/*
 *          LightComposition.glsl
 *
 */

//------------------------------------------------------------------------------


-- Fragment

// IN
in vec2 vTexCoord;

// OUT
out vec4 fragColor;

// UNIFORM
uniform sampler2D uDiffuseTex;
uniform sampler2D uLightingTex;

void main()
{
  // ++ Simple composition model ++
  
  vec4 buffer = texture( uDiffuseTex, vTexCoord);  
  vec3 albedo = buffer.rgb;
  float alpha = buffer.a;
  
  vec3 lighting = texture( uLightingTex, vTexCoord).rgb;
  
  fragColor.rgb = albedo;  
  if (alpha > 0.0f) fragColor.rgb *= lighting;
  
  fragColor.a = 1.0f;
}

